Arduino Tutorial: IR Distance / Line Tracing / Line Tracking Sensor (MH Sensor Series/KY

您所在的位置:网站首页 flying fish传感器是什么 Arduino Tutorial: IR Distance / Line Tracing / Line Tracking Sensor (MH Sensor Series/KY

Arduino Tutorial: IR Distance / Line Tracing / Line Tracking Sensor (MH Sensor Series/KY

2024-07-18 00:38:16| 来源: 网络整理| 查看: 265

IR distance sensor (MH Sensor Series, KY-033, TCRT5000).IR distance sensor (MH Sensor Series, KY-033, TCRT5000).

In this tutorial, it is shown how to use an IR distance sensor with an Arduino Uno. The todays sensor comes in many names: MH Sensor Series, KY-033 (variant with 3 pins), TCRT5000, etc. Moreover, it is often advertised as IR distance sensor, line tracing sensor or line tracking sensor.In addition to the IR distance sensor, this tutorial makes use of an LCD module called “LCM1602 IIC V1” which is utilized to show sensor values. The main advantage of the LCM1602 IIC V1 is that it is very easy-to-use. For example, it can be controlled by setting up an I2C connection.

List of materials:

Arduino UnoJumper wiresMini breadboardMH Sensor SeriesLCM1602 IIC V1 (LCD)

Remark: Some variants of the module type, such as the KY-033, have only three pins. Typically, the A0 pin is missing. Moreover, the D0 pin is often labeled as S. If you own such a variant, this tutorial is still of use to you. Just ignore the part related to the A0 pin.

Pin layout:

The scheme shows how to wire the MH Sensor Series and the LCM1602 IIC V1 to an Arduino Uno.

The IR sensor and the LCM1602 module have only four pins. The GND pins of both modules must be connected to the Arduino’s GND pins. The same applies to the VCC pins which must be connected to the Arduino’s 5V pin. As the Arduino Uno has only a single 5V pin, a mini breadboard is used to “split” the 5V pin. Next, the A0 and D0 pin of the IR sensor must be connected to the Arduino. The A0 pin is the raw analog value (0-1023) of the measured distance between the sensor and an obstacle. In this tutorial, A0 is connected to the Arduino’s A0 pin. The D0 pin is a digital pin that goes to HIGH state if the analog value is greater than or equal to a specific threshold. The threshold can be adjusted by the blue trimpot of the IR distance sensor. Here, D0 is connected to the Arduino’s pin 8.As a last step, the LCM1602 module’s SDA and SCL pins must be connected to the corresponding SDA and SCL pins of the Arduino Uno.

Example source code

// (c) Michael Schoeffler 2017, http://www.mschoeffler.de #include #include LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // initializes the LCM1602 IIC V1 (LCD module) // 0x27 is the I2C address. This address might be different. const int IN_A0 = A0; // analog input const int IN_D0 = 8; // digital input void setup() { pinMode (IN_A0, INPUT); pinMode (IN_D0, INPUT); lcd.begin(16, 2); // begins connection to the LCD module lcd.backlight(); // turns on the backlight } int value_A0; bool value_D0; void loop() { value_A0 = analogRead(IN_A0); // reads the analog input from the IR distance sensor value_D0 = digitalRead(IN_D0);// reads the digital input from the IR distance sensor lcd.setCursor(0, 0); // sets the cursor of the LCD module to the first line lcd.print("A0:"); lcd.setCursor(3, 0); // sets the cursor of the LCD module to the fourth character lcd.print(value_A0); // prints analog value on the LCD module lcd.setCursor(0, 1); // sets the cursor of the LCD module to the first line lcd.print("D0:"); lcd.setCursor(3, 1); // sets the cursor of the LCD module to the fourth character lcd.print(value_D0); // prints digital value on the LCD module delay(1000); }

If the code has been compiled and transmitted to the Arduino Uno, the LCD module should show the distance between the IR distance sensor and an obstacle. Keep in mind that the distance is indicated by a analog value between 0 and 1023. Unfortunately, it is very challenging to convert the analog value to a metric unit of length, such as meter or centimeter. The reason is that the measured analog value is strongly influenced by the obstacle’s material. For example, black surface does reflect far less light than white surface. As a consequence, the measured analog value will differ. Interestingly, this characteristic can be used in order to use the IR distance sensor as a “black or white” detector. This application can often be found in “car assembly kits” where multiple IR sensors are mounted on the undercar. As a result, the car is capable of following a black line that is drawn on white ground.

The following pictures show distance measurements with black and white material. Although the distance is about the same, the measured analog value (A0) differs strongly:

The IR distance sensor measures black material. The analog sensor value is much higher than when measuring white material (A0 = 949).The IR distance sensor measures white material. The analog sensor value is much lower than when measuring black material (A0 = 525).

Video tutorial

Tutorial: MH Sensor Series/KY-033/TCRT5000 + LCM1602 IIC V1 | UATS A&S #13


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭